package com.neuedu.controller.depttype;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.neuedu.factory.ClassFactory;
import com.neuedu.service.DeptClassityService;
import com.neuedu.service.DeptTypeService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

@WebServlet(name = "QueryTypeServlet", urlPatterns = "/his/querytype")
public class QueryTypeServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String Typename = request.getParameter("Typename");
        String id = request.getParameter("id");
        Typename = "%" + Typename + "%";
        id = "%" + id + "%";
        Object[] objs = {Typename, id};
        ObjectMapper om = new ObjectMapper();
        DeptTypeService dcs = (DeptTypeService) ClassFactory.createObj("DeptTypeService");
        List<Map<String, Object>> list = dcs.likeQuery(objs);
        String s = om.writeValueAsString(list);
        PrintWriter writer = response.getWriter();
        writer.append(s);
    }
}
